package com.bosssoft.setp.model.business.course;

import com.bosssoft.setp.handler.ChoiseFetchHandlerImpl;
import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.*;
import xyz.erupt.jpa.model.BaseModel;
import javax.persistence.*;

/**
 * 课程详细实体的类定义
 *
 * @author clt
 */
@Entity
@Table(name = "setp_course_detail")
@Erupt(name = "课程管理",
        power = @Power(add = true, delete = true,
                edit = true, query = true,
                importable = true, export = true)
)
public class CourseDetail extends BaseModel {

    @Column(name = "course_id")
    private Long courseId;

    @EruptField(
            views = @View(title = "附件"),
            edit = @Edit(title = "附件",
                    notNull = true,
                    type = EditType.ATTACHMENT,
                    attachmentType = @AttachmentType)
    )
    @Column(name = "attachment_url")
    private String attachmentUrl;

    @EruptField(
            views = @View(title = "是否允许下载"),
            edit = @Edit(title = "是否允许下载", notNull = true, boolType = @BoolType(trueText = "允许", falseText = "不允许"), search = @Search)
    )
    private  Boolean allowDownload;

    @EruptField(
            views = @View(title = "默认附件"),
            edit = @Edit(title = "默认附件", notNull = true, boolType = @BoolType(trueText = "是", falseText = "不是"), search = @Search)
    )
    private Boolean isDefault;

    @EruptField(
            views = @View(title = "附件类别"),
            edit = @Edit(title = "附件类别",
                    search = @Search,
                    type = EditType.CHOICE,
                    notNull = true,
                    choiceType = @ChoiceType(
                            fetchHandler = ChoiseFetchHandlerImpl.class,
                            fetchHandlerParams = {"附件类别"}
                    ))
    )
    private String attachmentType;

    public Long getCourseId() {
        return courseId;
    }

    public boolean isDefault() {
        return this.isDefault;
    }

    public void setCourseId(Long id) {
        this.courseId = id;
    }
}